/**
 * Copyright (C) 2022-2023 Timber Chain Cloud (TimberCLD). All Rights Reserved.
 *
 * @author: luoweijian
 * @email: 807301075@qq..com
 * @site: https://www.timbercld.com/
 *
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 *  limitations under the License.
 */
import http from '@/utils/request';

const url = '/timbercld'; // 默认url前缀，可新增其他api配置

export const systemApi = {
  // #region 用户接口
  getUserPage: `${url}/system/user/page`, // 列表
  deleteUser: `${url}/system/user`, // 删除
  exportUser: `${url}/system/user/export`, // 导出
  getRoleList() {
    // 获取角色列表
    return http.get(url + '/system/role/list');
  },
  insertUser(data: object) {
    // 新增用户
    return http.post(url + '/system/user', data);
  },
  getUserInfo(id: string) {
    // 获取用户信息
    return http.get(url + `/system/user/${id}`);
  },
  updateUser(data: object) {
    // 修改用户
    return http.put(url + '/system/user', data);
  },
  // #endregion

  // #region 部门接口
  getDeptUrl: `${url}/system/dept/list`, // 列表url
  deleteDeptUrl: `${url}/system/dept`, // 删除
  getDeptList() {
    // 获取部门列表
    return http.get(systemApi.getDeptUrl);
  },
  insertDept(data: object) {
    // 新增部门
    return http.post(url + '/system/dept', data);
  },
  getDeptInfo(id: string) {
    // 获取部门信息
    return http.get(url + `/system/dept/${id}`);
  },
  updateDept(data: object) {
    // 修改部门
    return http.put(url + '/system/dept', data);
  },
  // #endregion

  // #region 角色接口
  getRoleListUrl: `${url}/system/role/page`, // 列表
  deleteRole: `${url}/system/role`, // 删除

  getMenuSelect() {
    // 获取菜单列表
    return http.get(url + '/system/menu/select');
  },
  insertRole(data: object) {
    // 新增角色
    return http.post(url + '/system/role', data);
  },
  getRoleInfo(id: string) {
    // 获取角色信息
    return http.get(url + `/system/role/${id}`);
  },
  updatetRole(data: object) {
    // 修改角色
    return http.put(url + '/system/role', data);
  },
  // #endregion

  // #region 菜单接口
  getMenuListUrl: `${url}/system/menu/list`, // 列表
  deleteMenu: `${url}/system/menu`, // 删除
  getMenuList() {
    return http.get(`${systemApi.getMenuListUrl}?type=0`);
  },
  insertMenu(data: object) {
    // 新增角色
    return http.post(url + '/system/menu', data);
  },
  getMenuInfo(id: string) {
    // 获取角色信息
    return http.get(url + `/system/menu/${id}`);
  },
  updateMenu(data: object) {
    // 修改角色
    return http.put(url + '/system/menu', data);
  },
  // #endregion

  // #region  参数接口
  getParamsPageUrl: `${url}/system/params/page`, // 列表
  deleteParams: `${url}/system/params`, // 删除
  insertParams(data: object) {
    // 新增参数
    return http.post(url + '/system/params', data);
  },
  getParamsInfo(id: string) {
    // 获取参数信息
    return http.get(url + `/system/params/${id}`);
  },
  updateParams(data: object) {
    // 修改参数
    return http.put(url + '/system/params', data);
  },
  // #endregion

  // #region 日志接口
  loginLoggerPageUrl: `${url}/system/logger/login/page`,
  loginLoggerExport: `${url}/system/logger/login/export`,
  operationLoggerPageUrl: `${url}/system/logger/operation/page`,
  operationLoggerExport: `${url}/system/logger/operation/export`,
  errorLoggerPageUrl: `${url}/system/logger/error/page`,
  errorLoggerExport: `${url}/system/logger/error/export`,

  // #endregion
};
